package com.jsmile.cloud.authc.web.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import com.jsmile.mall.api.kit.StrKit;

import lombok.Data;

@Data
@Configuration
@ConfigurationProperties(prefix = "jsmile.authc")
public class AuthcConfig {

    /**
     * 是否短信验证
     */
    private Boolean hasVerifyCode;
    /**
     * 短信验证白名单
     */
    private String verifyPhones;

    /**
     * 是否验证手机号码
     */
    public boolean hasVerifyPhone(String phone) {
        if (!this.getHasVerifyCode() || !(StrKit.isNotEmpty(this.getVerifyPhones()) && this.getVerifyPhones().contains(phone))) {
            return false;
        }
        return true;
    }
}
